package com.hjl.hos_hjl_test2.slice;

import com.hjl.hos_hjl_test2.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
import ohos.agp.components.Text;

public class MainAbilitySlice extends AbilitySlice {
    Text text;
    Button login;
    Button register;
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);
         text = (Text) this.findComponentById(ResourceTable.Id_text_change);
         login = (Button) this.findComponentById(ResourceTable.Id_button_login);
       register = (Button) this.findComponentById(ResourceTable.Id_button_register);
       login.setClickedListener(new Component.ClickedListener() {
           @Override
           public void onClick(Component component) {
               text.setText("登录按钮点击");
           }

       }
       );
       register.setClickedListener(new Component.ClickedListener() {
                                       @Override
                                       public void onClick(Component component) {
                                           text.setText("注册按钮点击");
                                       }

                                   }
       );

    }


    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
